import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.LineNumberReader;


public class  HMMProcessing{
      public static void main(String[] args){
                HMMProfile HMM=new HMMProfile();
                ReadHMMProfile ReadProfile = new ReadHMMProfile("/Users/OuHan/Desktop/FloatCloudTest/sample.hmm");
                ProteinSeq Sequence=new ProteinSeq();
                ReadProteinSeq ReadProcess=new ReadProteinSeq();
                //ReadProcess.OpenProteinSeqFile();
                Viterbi ViterbiProcess=new Viterbi();
                File ProteinFile = new File("/Users/OuHan/Desktop/FloatCloudTest/input/test.fasta");
                FileReader freader = null;
                try {
                        freader = new FileReader(ProteinFile);
                } catch (FileNotFoundException e1) {
                        // TODO Auto-generated catch block
                        e1.printStackTrace();
                }
                LineNumberReader lnreader = new LineNumberReader(freader);
                String line=new String();
                try {
                        while((line=lnreader.readLine())!=null){
                                try {
                                        int Flag=ReadProcess.MapToProteinSeq(Sequence,line);
                                        if(Flag==1|| Flag==2){
                                        		
                                                while(ReadProfile.ReadNextProfile( HMM ))
                                                {
                                                        Double score=ViterbiProcess.ViterbiAlgorithm(Sequence, HMM);
                                                        String SeqNo1=new String();
                                                        SeqNo1=Sequence.GetSeqNo();
                                                        System.out.println(Sequence.GetSeqNo()+":"+score.toString());
                                                        
                                                        HMM.ResetHMMProfile();
                                                }
                                                ReadProfile.Reset();
                                        if(Flag==2){
                                                break;
                                        }
                                        }
                                } catch (IOException e) {
                                        // TODO Auto-generated catch block
                                        e.printStackTrace();
                                }
                               
                        }
                } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }
        }
}



